/*
 *  Network.h
 *  SquirrelAdven
 *
 *  Created by Andrew on 3/14/11.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */


/*
0 - Chat
1 - Info
2 - Move
etc
*/


#if defined(_WIN32) || defined(WIN32) 
#define OS_WIN
#endif

#ifdef OS_WIN
//Windows specific stuff
#define OS 0
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdio.h>
#pragma comment(lib, "Ws2_32.lib")

class WinSockNetwork {
protected:
	char* connectToIP;
	SOCKET ConnectSocket;

public:
	//constructor
	WinSockNetwork();
	// destructor
	~WinSockNetwork();
	//send stuff out on the socket to server
	void sendMessage(char* sendbuf);
	//used to read from the socket to server
	int receiveMessage(char* recvbuf);
};

#else
//Mac related stuff
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>

#include <arpa/inet.h>

#define PORT "5678" // the port client will be connecting to 

#define MAXDATASIZE 256 // max number of bytes we can get at once 
void *get_in_addr(struct sockaddr *sa);
class BSDNetwork {
protected:
	//pointer to sq client? so it can call sqclient.checkmsg()
	//char* connectToIP;
	//SOCKET ConnectSocket;
	int sockfd;

public:
	//constructor
	BSDNetwork();
	// destructor
	~BSDNetwork();
	//send stuff out on the socket to server
	void sendMessage(char* sendbuf);
	//used to read from the socket to server
	int receiveMessage(char *recvbuf);

};
#endif
